package com.godme.sort;

import java.util.Arrays;

public class BubblingSort {

    public static void sort(int[] arr){
        int maxIndex = arr.length - 1;
        int temp;
        for(int iter=0; iter < maxIndex; iter++){
            for(int index=0; index < maxIndex - iter; index++){
                if(arr[index] > arr[index+1]){
                    temp = arr[index+1];
                    arr[index+1] = arr[index];
                    arr[index] = temp;
                }
            }
        }
    }


    public static void main(String[] args) {
        int[] arr = {9,8,7,6,5,4,3,2,1};
        sort(arr);
        System.err.println(Arrays.toString(arr));
    }


}
